package cn.initcap.concurrency.concurrency.unsafe;

import cn.initcap.concurrency.annoations.ThreadSafe;
import cn.initcap.concurrency.concurrency.ThreadPoolCreatHelper;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

/**
 * 使用joda-time提供的方法，线程安全，项目中推荐使用joda-time。
 *
 * @author initcap
 * @date Created in 2018/6/16 PM1:33.
 */
@Slf4j
@ThreadSafe
public class DateFormatJodaTime {

    /**
     * 总请求数
     */
    private static final int CLIENT_TOTAL = 5000;

    /**
     * 同时并发执行的线程数
     */
    private static final int THREAD_TOTAL = 200;

    private static DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd");

    public static void update() {
        DateTime.parse("2018-02-08", dateTimeFormatter).toDate();
    }

    public static void main(String[] args) {
        ThreadPoolCreatHelper.threadPoolRun(CLIENT_TOTAL, THREAD_TOTAL,
                DateFormatJodaTime.class, "update",
                "DateFormatJodaTime");
    }

}
